package com.apes.fico.engine.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.fico.masterdata.gl.model.AccountingOperatingChartAuxiliary;
import com.apes.framework.jpa.ApesBean;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.metadata.BusinessField;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;


@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ReduceVoucherAuxiliary.CONST_TABLE_NAME)
public class ReduceVoucherAuxiliary implements ApesBean {
    public final static String CONST_TABLE_NAME = "gl_voucher_aux_reduce";

    @Id
    @JSONField(serialize = false)
    @Column(name = "id", length = 120)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "财务凭证辅助核算", padding = 8)
    @Comment("编码")
    private String id;

    @ManyToOne(optional = false)
    @JoinColumn(name = "voucher_item_id", referencedColumnName = "id", nullable = false)
    @Comment("归约分录编码")
    private ReduceVoucherItem voucherItem;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "acc_aux_id", referencedColumnName = "id")
    @Comment("辅助类型标识")
    private AccountingOperatingChartAuxiliary accountingOperatingChartAuxiliary;

    @Column(name = "code", nullable = false, length = 64)
    @Comment("内容代码")
    private String code;

    @Column(name = "name", nullable = false, length = 200)
    @Comment("内容名称")
    private String name;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "business_field", referencedColumnName = "id")
    @Comment("通用属性名")
    private BusinessField businessField;

}
